<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>无标题文档</title>
	<link href="/res/css/style.css" rel="stylesheet" type="text/css" />
	<link href="/res/js/lib/layer/skin/layer.css" rel="stylesheet" type="text/css" />
	<link href="/res/js/lib/layer/skin/layer.ext.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="/res/js/jquery.js"></script>
	<script type="text/javascript" src="/res/js/lib/json2.js"></script>	
	<script type="text/javascript" src="/res/js/lib/layer/layer.js"></script>
	<script type="text/javascript" src="/res/js/common/msgTools.js"></script>
	<script language="javascript" type="text/javascript" src="/res/js/lib/datePicker/WdatePicker.js"></script>		
    <script type="text/javascript" src="/res/js/pages/system/permSet.js"></script>

<style>
   .menu{font-size: 16px;line-height: 30px;}
   .menu .level1{font-weight: bold;height:30px;margin:3px; padding:3px;background: url("/res/images/lefttop.gif") repeat-x scroll 0 0;}
   .menu .level2{font-weight: bold;}
   .menu .level3{font-weight: normal;}
   .odd{background-colorx: #efefef;}
</style>
</head>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">权限管理</a></li>
    <li><a href="#">角色权限</a></li>
    </ul>
    </div>
    
    <div class="rightinfo" style="padding-bottom:60px;">
	    <form id="queryForm" action="/system/perm/set" method="post"> 
	    <div class="tools" style="margin:3px 0px;background: #efefef;padding:6px 0px;">   
	        <span class="toolbar" style="margin-left:10px;">
			   角色：	
	 			   <select id="ddlRole" class="dfinput"  name="role" style="width:150px;line-height:30px;font-size:14px;" onchange="submit()">
					  <option value="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--请选择--  </option>
					  <c:forEach items="${roleList}" var="role">
					     <option value="${role.id}" ${role.id==roleId?"selected":""}>${role.name}</option>
					  </c:forEach>
				   </select>           
	        </span>
	    	<ul class="toolbar1" style="margin-left:20px;">
		        <li onclick="if(checkDat())$('#saveForm').submit()"><span><img src="/res/images/t02.png" /></span>保存</li>
	        </ul>    
	    </div>
	    </form>
	
	    <form id="saveForm" action="/System/perm/save/${(empty roleId)?-1:roleId}" method="post">	    
			<ul class="menu">
				<c:forEach items="${moduleList}" var="md">
					<c:if test="${md.level==1}">
						<li>
						    <div class="level1">
							    <input id="chk_${md.id}" name="moduleId" type="checkbox" value="${md.id}" />
							    <label for="chk_${md.id}">${md.name}</label>
						    </div>
						    <!-- 二级菜单 -->						    
							<ul style="margin-left:30px;">
								<c:forEach items="${moduleList}" var="md2">
									<c:if test="${md2.level==2 && md2.parentId==md.id}">
										<li>
										   <div class="level2">
										     <input id="chk_${md2.id}" name="moduleId" type="checkbox" value="${md2.id}" />
										     <label for="chk_${md2.id}">${md2.name}</label>
										   </div>
										   
										    <!-- 三级菜单 -->						    
											<ul style="margin-left:30px;">
												<c:forEach items="${moduleList}" var="md3">
													<c:if test="${md3.level==3 && md3.parentId==md2.id}">														
														<li>
														   <div class="level3">
														     <input id="chk_${md3.id}" name="moduleId" type="checkbox" value="${md3.id}" />
														     <label for="chk_${md3.id}">${md3.name}</label>
														   </div>
														</li>
												    </c:if>
											    </c:forEach>	
											</ul>											   
										   
										</li>
								    </c:if>
							    </c:forEach>	
							</ul>	
						</li>
					</c:if>
				</c:forEach>
			</ul>
		</form>
    </div>
    <script type="text/javascript">
	   $('.level1:odd').addClass('odd');
	   var perms=${perms};
	   $(function(){
		   $(perms).each(function(i,o){
			   $("#chk_"+o).get(0).checked=true
		   });		   
	   });
	</script>
${actionMsg}
</body>

</html>
